<?php
namespace App\Library\System\Model;

use App\Library\System\Model;
use Zend\Http\Header\UserAgent;
use Zend\Session\Validator\HttpUserAgent;

class UserModel extends Model
{
    public function __construct($id)
    {
        parent::__construct();

        $user = $this->one($this->select()
                ->from('user')
                ->where(array(
                    'id' => $id
                ))
        );

        // Integrate user's informations into this object as properties
        if ($user) {
            $this->add($user);
        }
    }

    // User is valid ?
    public function isValid()
    {
        return isset($this->id) ? true : false;
    }

    public function getTitle()
    {
        return $this->name;
    }

    public function getDescription()
    {
        $description = $this->slogan;

        return $description;
    }

    public function getNationality($alias = false)
    {
        $nationality = $this->one($this->select()
                ->from('country')
                ->where(array(
                    'id' => $this->nationality
                ))
        );

        return $alias ? $nationality->alias : $nationality->name;
    }

    public function getSocial($list)
    {
        return $this->one($this->select()
                ->columns($list)
                ->from('social')
                ->where(array(
                    'user_id' => $this->id
                ))
        );
    }

    public function getSignature()
    {
        $str = $this->name . $this->password . $this->email . $_SERVER['HTTP_USER_AGENT'] . $_SERVER['REMOTE_ADDR'];
        $sha1 = sha1($str);

        return hash('sha512', $sha1) . hash('sha384', $sha1);
    }

    public function getFullName()
    {
        return $this->name;
    }

    public function getHeadLine()
    {
        return $this->headline;
    }

    public function getProfessional()
    {
        return 'Computer Programming';
    }

    public function getCurrent()
    {
        return $this->current;
    }

    public function getPrevious()
    {
        return $this->previous;
    }

    public function getEducation()
    {
        return $this->education;
    }

    public function getEmail()
    {
        return $this->email;
    }

    public function getAlias()
    {
        return $this->alias;
    }

    public function getAvatar()
    {
        $default = 'default.jpg';

        return $this->avatar ? $this->avatar : $default;
    }

    public function getLanguage()
    {

    }

    public function getCountry_Alias()
    {
        return 'vietnam';
    }

    public function getRegisterDate()
    {

    }

}